package com.lhn.tankGame4;

/**
 * @author lhn
 * @date 2024-07-24 17:59
 */

public class Tank {
    private int x;
    private int y;
    private int direction;
    private int speed = 10;

    public Tank() {
    }

    public Tank(int x, int y, int direction) {
        this.x = x;
        this.y = y;
        this.direction = direction;
    }

    public Tank(int x, int y, int direction, int speed) {
        this.x = x;
        this.y = y;
        this.direction = direction;
        this.speed = speed;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDirection() {
        return direction;
    }

    public void setDirection(int direction) {
        this.direction = direction;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    @Override
    public String toString() {
        return "Tank{" +
                "x=" + x +
                ", y=" + y +
                ", direction=" + direction +
                ", speed=" + speed +
                '}';
    }

    //移动方法
    public void moveUp() {
        this.direction = 0;
        this.y = this.y - this.speed;
    }

    public void moveRight() {
        this.direction = 1;
        this.x = this.x + this.speed;
    }

    public void moveDown() {
        this.direction = 2;
        this.y = this.y + this.speed;
    }

    public void moveLeft() {
        this.direction = 3;
        this.x = this.x - this.speed;
    }
}
